package com.oig.sys.auth.dto;


import com.oig.common.validator.GroupAdd;
import com.oig.common.validator.GroupEdit;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import javax.validation.Valid;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.List;

@Data
@Schema(description = "菜单按钮参数对象")
public class ResourceDto {

    @Schema(description = "主键id", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
    @NotNull(message = "参数错误,id不能为空", groups= GroupEdit.class)
    private Integer id;

    @Schema(description = "所属子系统id 预留", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
    @NotNull(message = "参数错误，所属系统不能为空", groups={GroupAdd.class, GroupEdit.class})
    private Integer systemId;

    @Schema(description = "编码", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
    @NotEmpty(message = "参数错误，编码不能为空", groups={GroupAdd.class, GroupEdit.class})
    private String resourceCode;
    @Schema(description = "菜单按钮名称", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
    @NotEmpty(message = "参数错误，名称不能为空", groups={GroupAdd.class, GroupEdit.class})
    private String resourceName;

    @Schema(description = "排序序号")
    private Integer sort;

    @Schema(description = "图标样式class")
    private String icoClass;

    @Schema(description = "上级菜单id")
    private Integer parentId;

    @Schema(description = "请求地址，主菜单可能有，前端用")
    private String pathUrl;

    @Schema(description = "按钮事件，按钮可能有，前端用")
    private String uiEvent;

    @Schema(description = "查询json描述符")
    private String jsonText ;

    @Schema(description = "是否支持通用查询")
    private String queryType;   //是否支持通用查询 0-通用查询 1-接口查询

    @Schema(description = "通用查询固定查询条件配置,格式[{\"fieldName\":\"status\",\"symbol\":\"$in\",\"value\":[01,02]},{\"fieldName\":\"payStatus\",\"symbol\":\"$eq\",\"value\":\"01\"}],map的json只支持and条件")
    private String queryConditionCfg ;
    @Schema(description = "通用查询,默认排序配置 格式{\"field\":\"ASC\"}")
    private String querySortCfg ;

    @Schema(description = "列表查询接口地址")
    private String apiUrl ;

    @Schema(description = "列表界面是否支持tab子页0否 1是")
    private String isSupportTab;
    @Schema(description = "tab子页查询配置")
    private String tabCfgJson;

    @Schema(description = "是否在主菜单里显示 0-不显示 1-显示")
    private String isShow;

    @Schema(description = "是否纯粹查询界面 0-否 1-是")
    private String isQueryOnly;

    @Schema(description = "是否允许删除 1-允许 0-不允许")
    private String noDelFlag;

    @Schema(description = "功能说明,当不为空时，可以在按钮或菜单里tip展示")
    private String remark;
    @Schema(description = "数据隔离范围 1-不隔离 2-按租户隔离")
    private String isPublicData;

    @Schema(description = "添加列表菜单时，需要加上列表展示的所有列")
    @Valid
    private List<ResourceColumnDto> resourceColumnList ;

    @Schema(description = "菜单所需接口权限列表")
    private List<PermissionDto> permissionList ;

    /*先做单独配置
        一个用户可以有，多个角色，多个岗位，多个部门
        如果有重叠配置，如何处理？用白名单排除不需要的限制？
     */
//    @Schema(description = "菜单数据权限配置")
//    @Valid
//    private List<ResourceDataCfgDto> resourceDataCfgList;


}
